package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QCkpj;
import com.ruoyi.system.service.IQCkpjService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务窗口评价Controller
 * 
 * @author ruoyi
 * @date 2024-07-03
 */
@Controller
@RequestMapping("/system/ckpj")
public class QCkpjController extends BaseController
{
    private String prefix = "system/ckpj";

    @Autowired
    private IQCkpjService qCkpjService;

    @RequiresPermissions("system:ckpj:view")
    @GetMapping()
    public String ckpj()
    {
        return prefix + "/ckpj";
    }

    /**
     * 查询服务窗口评价列表
     */
    @CrossOrigin
    @RequiresPermissions("system:ckpj:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QCkpj qCkpj)
    {
        startPage();
        List<QCkpj> list = qCkpjService.selectQCkpjList(qCkpj);
        return getDataTable(list);
    }

    /**
     * 导出服务窗口评价列表
     */
    @CrossOrigin
    @RequiresPermissions("system:ckpj:export")
    @Log(title = "服务窗口评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QCkpj qCkpj)
    {
        List<QCkpj> list = qCkpjService.selectQCkpjList(qCkpj);
        ExcelUtil<QCkpj> util = new ExcelUtil<QCkpj>(QCkpj.class);
        return util.exportExcel(list, "服务窗口评价数据");
    }

    /**
     * 新增服务窗口评价
     */
    @CrossOrigin
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存服务窗口评价
     */

    // @RequiresPermissions("system:ckpj:add")
    @Log(title = "服务窗口评价", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @CrossOrigin
    public AjaxResult addSave(@RequestBody QCkpj qCkpj)
    {
        return toAjax(qCkpjService.insertQCkpj(qCkpj));
    }

    /**
     * 修改服务窗口评价
     */
    @CrossOrigin
    @RequiresPermissions("system:ckpj:edit")
    @GetMapping("/edit/{ckPingjiaId}")
    public String edit(@PathVariable("ckPingjiaId") Long ckPingjiaId, ModelMap mmap)
    {
        QCkpj qCkpj = qCkpjService.selectQCkpjByCkPingjiaId(ckPingjiaId);
        mmap.put("qCkpj", qCkpj);
        return prefix + "/edit";
    }

    /**
     * 修改保存服务窗口评价
     */
    @CrossOrigin
    @RequiresPermissions("system:ckpj:edit")
    @Log(title = "服务窗口评价", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QCkpj qCkpj)
    {
        return toAjax(qCkpjService.updateQCkpj(qCkpj));
    }

    /**
     * 删除服务窗口评价
     */
    @CrossOrigin
    @RequiresPermissions("system:ckpj:remove")
    @Log(title = "服务窗口评价", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qCkpjService.deleteQCkpjByCkPingjiaIds(ids));
    }
}
